/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-14
 * Time: 8:36
 */
public class Student {
    private String name;
    private String stuNum;
    private int age;

    static String className = "1班";//就地初始化

    {
        this.age = 20;
        this.name = "wang wu";
        System.out.println("实例代码块执行中......");
    }

    public void eat(){
        System.out.println(name + "正在吃饭!");
    }
    public void show(){
        System.out.println("姓名" + name + "学号" + stuNum + "年龄" + age + "班级" + className);

    }

    public Student(String name, String stuNum, int age) {
        this.name = name;
        this.stuNum = stuNum;
        this.age = age;

        className = "3班";
        System.out.println("构造方法初始化......");
    }

    public static String getClassName(){
        Student stu2 = new Student("li si","20230502108",18);
        stu2.show();

        return className;
    }

    public static void setClassName(String className) {
        Student.className = className;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", stuNum='" + stuNum + '\'' +
                ", age=" + age +
                '}';
    }

    static{
        className = "4班";
        System.out.println("静态代码块初始化......");
    }

    public static void main(String[] args) {
        getClassName();
//        Student stu1 = new Student("zhang san","20230502107",18);
//        Student stu2 = new Student("zhang sa","20230502108",18);
//        System.out.println(Student.className);
//        System.out.println(stu1.name);
//        System.out.println(stu1);

    }
}
